{% extends 'tasks/base.html' %}

{% block title %}登录{% endblock %}
{% block content %}
<div class="row justify-content-center zym">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h1>登录</h1>
            </div>
            <div class="card-body">
                <form method="post" novalidate>
                    {% csrf_token %}
                    
                    <div class="mb-3">
                        <label for="{{ form.username.id_for_label }}" class="form-label">用户名</label>
                        <input type="text" class="form-control {% if form.username.errors %}is-invalid{% endif %}" 
                               id="{{ form.username.id_for_label }}" name="{{ form.username.name }}" 
                               value="{{ form.username.value|default:'' }}">
                        {% if form.username.errors %}
                            <div class="invalid-feedback">
                                {{ form.username.errors }}
                            </div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.password.id_for_label }}" class="form-label">密码</label>
                        <input type="password" class="form-control {% if form.password.errors %}is-invalid{% endif %}" 
                               id="{{ form.password.id_for_label }}" name="{{ form.password.name }}">
                        {% if form.password.errors %}
                            <div class="invalid-feedback">
                                {{ form.password.errors }}
                            </div>
                        {% endif %}
                    </div>
                    
                    {% if form.non_field_errors %}
                        <div class="alert alert-danger">
                            {{ form.non_field_errors }}
                        </div>
                    {% endif %}
                    
                    <div class="d-flex justify-content-between align-items-center">
                        <button type="submit" class="btn btn-primary">登入</button>
                        <a href="{% url 'register' %}" class="text-decoration-none">没有账号？注册</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}